<%-- 
    Document   : yqbhsz
    Created on : 2016-7-4, 10:46:02
    Author     : cxhd
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../../link.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>仪器编号设置</title>
    </head>
     <style>
        tr>td{
            padding: 4px 4px 4px 4px;
            /*padding-bottom: 4px;*/
        }
        th{
            padding:4px 4px 4px 4px;
            font:bold;
            text-align:center;
        }
         .error{font-size: 1px; color: red}
    </style>
    <body style="font-family: 微软雅黑;margin-top: 10px;" ng-app="yqbh" ng-controller="mainTab">
         <div class="col-lg-12">
            <div class="panel panel-default" style="overflow: hidden">

                <div class="panel-heading"><span style="float: left">用户列表</span>
                    <div>
                        <input ng-model="searchContent"  placeholder="代码" style="width:320px; float: left;margin-left: 20px" class="form-control input-sm" />
                        <button ng-click="getList()" style="float: left" class="btn btn-success btn-sm"><span class="fa fa-search"></span>&nbsp;&nbsp;搜索</button>

                        <button ng-click="OpenSaveModal()" style="margin-left: 30px;float: left" class="btn btn-info btn-sm"><span class="fa fa-send"></span>&nbsp;&nbsp;添加</button></div>

                    <div style="clear: both"></div>
                </div>

                <table class="table table-striped table-bordered  table-hover ">
                    <thead>
                        <tr>
                            <th class="table-id">代码</th>
                            <!--<th class="table-title">仪器编号范围</th>-->
                            <th class="table-date">说明</th>
                            <th class="table-date am-hide-sm-only">分析仪器</th>
                            <!--<th class="table-date am-hide-sm-only">报告单格式</th>-->
                            <th class="table-date">分析科室</th>
                            <th class="table-date">样本类型</th>
                            <th class="table-date">样本类型输入</th>
                            <th class="table-date">标记名称</th>
                            <th class="table-date">默认说明</th>
                            <th class="table-date">默认项目</th>
                            <th>生成条码</th> 
                            <th class="table-set">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="list in lists">
                <!--ng-repeat="list in userlists"-->
                <td>{{list.PROFILENAME}}</td>
               <!--<td>仪器编号范围</td>  仪器编号范围-->
                <td>{{list.PROFILEDESCRIBE}}</td>
                <td>{{list.DEVICEID1}}</td><!-- 分析仪器-->
                <!--<td>{{list.DATAWINDOWNAME}}</td>-->
                <!--报告单格式-->
                <td>{{list.SECTION1}}</td>
                <!--分析科室-->
                <td>{{list.SAMPLETYPE1}}</td>
<!--                样本类型-->
                <td>{{list.DEFINPUT}}</td>
<!--                样本类型输入-->
                <td>{{list.BJMC}}</td>
                <!--标记名称-->
                <td>{{list.DEFNOTE}}</td>
<!--                默认说明-->
                <td>{{list.DEFHYXM}}</td>
<!--                默认项目-->
                <td>{{list.NOTES}}</td> 
<!--                生成条码-->
                <td>
                <button ng-click="OpenUpdateModal(list)" class="btn btn-success btn-xs"><span class="fa fa-edit"></span>修改</button>
                <button ng-click="deletePro(list)" class="btn btn-danger btn-xs"><span class="fa fa-dedent"></span>删除</button>
                </td>
            </tr>

                    </tbody>
                </table>
                 <footer class="panel-heading">
                    <div class="row">
                        <div style="text-align: center" >                
                            <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                        </div>
                    </div>
                </footer>

            </div>

        </div>

        
            <div class="modal fade mode-x" role="dialog" aria-labelledby="gridSystemModalLabel">
            <div class="modal-dialog" role="document">
                <form  name="fromProf" id="profile">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseModel()"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">{{title}}仪器</h4>
                    </div>
                    <div class="modal-body">
                        
                            <table style="width: 100%">                             
                                <tr>  
                                    <td>代码:</td><td><input ng-model="prof.PROFILENAME" name="profilename" id="profilename"type="text" class="form-control" ng-minlength=1 ng-maxlength=3 required>
                                        <div class="error" ng-show="fromProf.profilename.$dirty && fromProf.profilename.$invalid">
                                            <small class="error" ng-show="fromProf.profilename.$error.required">代码不能为空。</small>
                                            <small class="error" ng-show="fromProf.profilename.$error.minlength">代码长度不能小于1</small>
                                            <small class="error" ng-show="fromProf.profilename.$error.maxlength">代码长度不能大于3</small> 
                                            </div>
                                    </td>
                                <td>仪器编号范围:</td><td><input ng-model="prof.PROFILECODE" type="text" class="form-control"></td>
                                <td style="width:60px">说明: </td><td><input ng-model="prof.PROFILEDESCRIBE" type="text" class="form-control"></td>
                                </tr>
                                <tr>
                                <td>分析仪器:</td><td>
                                    <!--<input ng-model="DEVICEID" type="text" class="form-control">-->
                                     <!--<select ng-model="LXGX" ng-options="lxrgx.DMSB as lxrgx.DMMC for lxrgx in lxrgxs" style="width: 80px" >-->
                                      <select ng-model="prof.DEVICEID" ng-options="deviceset.DEVICEID as deviceset.DEVICENAME for deviceset in devicesets" style="width: 100px" >
                                </select>
                                </td>
                                <td>报告单格式:</td><td><input ng-model="prof.DATAWINDOWNAME" type="text" class="form-control"></td>
                                <td>分析科室:</td><td>
                                    <!--<input ng-model="SECTION" type="text" class="form-control">-->
                                    <select ng-model="prof.SECTION" ng-options="ksdm.KSDM as ksdm.KSMC for ksdm in ksdms" style="width: 100px" >
                                    </select>
                                </td>
                                 </tr>                        
                                <tr>
                                <td>样本类型:</td><td>
                                    <!--<input ng-model="SAMPLETYPE" type="text" class="form-control">-->
                                     <select ng-model="prof.SAMPLETYPE" ng-options="sampletype.SAMPLETYPE as sampletype.SAMPLEDESCRIBE for sampletype in sampletypes" style="width: 100px" >
                                    </select>
                                </td>
                                <td>样本类型输入:</td><td><input ng-model="prof.DEFINPUT" type="text" class="form-control"></td>
                                <td>标记名称:</td><td><input ng-model="prof.BJMC" type="text" class="form-control"></td>
                                 </tr>
                                <tr>
                                <td>默认说明:</td><td><input ng-model="prof.DEFNOTE" type="text" class="form-control"></td>
                                <td>默认项目:</td><td>
                                    <!--<input ng-model="DEFHYXM" type="text" class="form-control">-->
                                    <select ng-model="prof.DEFHYXM" ng-options="hyxm.HYID as hyxm.HYXM for hyxm in hyxms" style="width: 100px" ></select>
                                </td>
                                <td>生成条码:</td><td><input ng-model="prof.NOTES" type="text" class="form-control"></td> 
                                 </tr>
                                 
                               

                            </table>
                        

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="CloseModel()">关闭</button>
                        <button  ng-click="savePro()"  type="button" ng-disabled="fromProf.$invalid" class="btn btn-primary"><span class="fa fa-save"></span>&nbsp;&nbsp;保存</button>
                    </div>
                </div><!-- /.modal-content -->
                </form>
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        
        
    </body>
    <script>
         angular.module("yqbh", ['baseModule', 'ui.bootstrap'])
            .controller("mainTab", function ($scope,base) {
                var so = $scope;
                 $scope.searchContent="";
                 $scope.prof={PK:""};
                 
                $scope.data = {currentPage: 1};
                so.setPage = function (pageNo) {
                    $scope.data.currentPage = pageNo;
                };
                so.pageChanged = function () {
                   $scope.getList();
                };
                so.data.maxSize = 10;
                so.data.bigTotalItems = 20;
                so.data.bigCurrentPage = 1;
                so.data.pageSize = 10;
                
                $scope.getDeviceset=function(){//仪器
                    base.post("pro/getLisDeviceset").get(function(data){
                        if(data){
                        $scope.devicesets=data;
                    }
                    })
                }
                $scope.getKsdm=function(){//分析科室
                    base.post("pro/getLisKsdm").get(function(data){
                        if(data){
                             $scope.ksdms=data;
                        }
                    })
                }
                $scope.getSampletype=function(){//样本类型
                   base.post("pro/getLisSampletype").get(function(data){
                        if(data){
                            $scope.sampletypes=data;
                        }
                    })
                }
                $scope.getDefHyxm=function(){//默认项目
                    base.post("pro/getLisHyxm").get(function(data){
                        if(data){
                            $scope.hyxms=data;
                        }
                    })
                }
                $scope.getDeviceset();
                 $scope.getSampletype();
                 $scope.getKsdm();
                $scope.getDefHyxm();
                
                
                $scope.getList = function () {
                    base.post("pro/getProfiletestList",{pageSize: so.data.pageSize, currentPage: so.data.currentPage,searchContent:$scope.searchContent}).get( function (data) {
                        if (data) {
                            so.lists = data.list;
                            so.data.bigTotalItems = data.totalRow;
//                            $scope.$apply();                            
                        }
                    })
                };
                $scope.getList();
                $scope.deletePro=function(list){
                    base.post("pro/deleteProfiletestList",{pk:list.PK}).get(function(data){
                        if(data=='true'){
                            alert("删除成功！",1000);
                        }else{
                            alert("该数据被其他表使用不能删除",1000);
                        }
                        $scope.getList();
                        $scope.$apply();
                    })
                }
                 $scope.OpenSaveModal = function () {
                     $scope.title="新增";
                     $("#profilename").prop("readonly",false);
                    $(".mode-x").modal('show');
                }
                $scope.OpenUpdateModal=function(list){
                      $scope.title="修改";
                       $("#profilename").prop("readonly",true);
                      $scope.prof=list;
                    $(".mode-x").modal('show');   
                }
               $scope.CloseModel=function(){
                   $scope.prof={PK:""};
                   
               }
               $scope.savePro=function(){
//                 alert($scope.prof.PK!="");
                 if($scope.prof.PK!=""){//修改
                     base.post("pro/updateProfiletestList",$scope.prof).get(function(data){
                        if(data=='true'){
                            $scope.getList();
                            alert("修改成功");
                        }  
                     })
                 }else{//保存 PROFILENAME PROFILECODE PROFILEDESCRIBE DEVICEID DATAWINDOWNAME SECTION
                            //SAMPLETYPE DEFINPUT BJMC DEFNOTE DEFHYXM NOTES
                     base.post("pro/addProfiletestList",$scope.prof).get(function(data){
                    if(data=='true'){
                        $scope.getList();
                            alert("新增成功");
                        }  
                         
                     })
                 }  
                 $(".mode-x").modal('hide');
                 $scope.CloseModel();
               }
            })
    </script>
</html>
